// zh_gjw/pages/cuscenter/cuscenter.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
		allmoney: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
		var that = this
		that.setData({
			admin: wx.getStorageSync('adminlogin')
		})
    
		getApp().util.request({
			'url': 'entry/wxapp/cusname',
			'cachetime': '0',
			data:{admin:that.data.admin},
			success: function (res) {
				console.log(res)
				that.setData({
					cusname: res.data.res.cusname,
					level_name: res.data.res.level_name,
					reputation: res.data.res.reputation,
					stars: res.data.res.stars,
					xybzj: res.data.res.xybzj
				})
			}
		});
    that.identy()

		getApp().util.request({
			'url': 'entry/wxapp/balance',
			'cachetime': '0',
			data: { phone: that.data.admin },
			success: function (res) {
				
				if(res.data.code==200){
					that.setData({
						allmoney:res.data.allmoney
					})
				}
			}
		});
		
  },

  // 判断身份
  identy: function (e) {
    var that = this
    var openid = wx.getStorageSync('openid')
    getApp().util.request({
      url: 'entry/wxapp/Iscustomers',
      data: { phone: that.data.admin },
      success: function (res) {
        
        if (res.data.code == 200) {    //定制商家
          that.setData({
            zt: 1
          })
        } else if (res.data.code == 204 ||  res.data.code == 201 || res.data.code == 500 || res.data.code == 202) {  //普通商家  
        
          that.setData({
            zt: 0
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
		this.onLoad()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
	},
	orderdb: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/corder/corder?admin=' + that.data.admin + '&orderdb=orderdb',
		})
	},
	ordershot: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/corder/corder?admin=' + that.data.admin + '&ordershot=ordershot',
		})
	},
	ordermarket: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/corder/corder?admin=' + that.data.admin + '&ordermarket=ordermarket',
		})
	},
	orderstore: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/corder/corder?admin=' + that.data.admin + '&orderstore=orderstore',
		})
	},
	orderpri: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/corder/corder?admin=' + that.data.admin + '&orderpri=orderpri',
		})
	},
	dbm: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/cgoods/cgoods?admin=' + that.data.admin + '&dbm=dbm',
		})
	},
	shotm: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/cgoods/cgoods?admin=' + that.data.admin + '&shotm=shotm',
		})
	},
	marketm: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/cgoods/cgoods?admin=' + that.data.admin + '&marketm=marketm',
		})
	},
	storem: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/cgoods/cgoods?admin=' + that.data.admin + '&storem=storem',
		})
	},
	prim: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/cgoods/cgoods?admin=' + that.data.admin + '&prim=prim',
		})
	},
	shot: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/shot/shot?admin=' + that.data.admin,
		})
	},
	market: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/market/market?admin=' + that.data.admin,
		})
	},
	store: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/stores/stores?admin=' + that.data.admin,
		})
	},
	cash: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/cash/cash'
		})
	},
	reputation: function () {
		var that = this
		wx.navigateTo({
			url: '/zh_gjw/pages/reputation/reputation?admin=' + that.data.admin,
		})
	}

})